﻿// --------------------------------
// <copyright file="CalculationTest.cs" company="TRONSoft">
//     Copyright (c) TRONSoft.
// </copyright>
// <license>
//   This source code is subject to terms and conditions of the Microsoft
//   Public License. A copy of the license can be found in the License.html
//   file at the root of this distribution. If you cannot locate the
//   Microsoft Public License, please send an email to dlr@microsoft.com.
//   By using this source code in any fashion, you are agreeing to be bound 
//   by the terms of the Microsoft Public License. You must not remove this
//   notice, or any other, from this software.
// </license>
// <author>Tron</author>
// ---------------------------------

using System;
using System.Globalization;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tronsoft.Actucal.CalculationEngineCreator.Test
{
    /// <summary>
    ///This is a test class for CalculationTest and is intended
    ///to contain all CalculationTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CalculationTest
    {
        private CultureInfo originaltCulture = Thread.CurrentThread.CurrentCulture;
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        }

        //Use TestCleanup to run code after each test has run
        [TestCleanup()]
        public void MyTestCleanup()
        {
            Thread.CurrentThread.CurrentCulture = originaltCulture;
        }

        #endregion

        /// <summary>
        ///A test for CalculationParameter
        ///</summary>
        [TestMethod()]
        [DeploymentItem("CalculationEngineCreator.dll")]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Constructor_Throw_Exception_Because_Expression_Is_Null()
        {
            Calculation target = new Calculation(null);
        }

        /// <summary>
        ///A test for CalculationParameter
        ///</summary>
        [TestMethod()]
        [DeploymentItem("CalculationEngineCreator.dll")]
        public void The_Source_Property_Should_Be_Correct_With_Parameters()
        {
            //            Expression exp = new Expression("name", "1 + ${p1} + ${p2}+${p3}");
            //            CalculationParameterCollection ps = new CalculationParameterCollection();
            //            ps.Add(new CalculationParameter("p1", 1));
            //            ps.Add(new CalculationParameter("p2", "2"));
            //            ps.Add(new CalculationParameter("p3", 3.5));

            //            Calculation target = new Calculation(exp, ps);
            //            string source = target.GenerateSource();
            //            string correctSource = @"Public Function name_CalculationFunction(p1 As System.Int32, p2 As System.String, p3 As System.Double) As Double
            //    Return  1 + p1 + p2+p3
            //End Function";
            //            Assert.AreEqual(source, correctSource);
        }
    }
}
